package com.cgbl.cg.ui.mine

import android.os.Bundle
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.cgbl.cg.BR
import com.cgbl.cg.R
import com.cgbl.cg.adapter.CourseAdapter
import com.cgbl.cg.adapter.OfflineCacheAdapter
import com.cgbl.cg.databinding.AppActivityOfflineCacheBinding
import com.cgbl.cg.view.CommonConfirmPop
import com.cgbl.cg.view.PersonalSignPop
import com.cgbl.cg.vm.mine.OfflineCacheViewModel
import com.lxj.xpopup.XPopup
import com.robot.base.base.activity.GLBaseActivity
import com.robot.base.configs.AppConstants
import com.robot.base.utils.pic.ImageLoaderUtils

@Route(path = AppConstants.Router.Mine.A_MINE_OFFLINE_CACHE)
class OfflineCacheActivity :
    GLBaseActivity<AppActivityOfflineCacheBinding, OfflineCacheViewModel>() {

    lateinit var offlineCacheAdapter: OfflineCacheAdapter

    private lateinit var deletePop: CommonConfirmPop


    override fun initComponents() {
        initTiterBar()
        initView()
    }

    override fun initViewObservable() {
        viewModel.uc.doAllDelete.observe(this) {
            XPopup.Builder(this)
                .asCustom(deletePop)
                .show()
            deletePop.setTitle("确认全部删除吗?")
                .setLeftText("取消")
                .setRightText("删除")
                .setRightClickListener {

                }
        }
    }


    private fun initTiterBar() {
        val titleView = findViewById<TextView>(R.id.tv_title)
        val backView = findViewById<ImageView>(R.id.iv_back)
        titleView.text = "离线缓存"
        backView.setOnClickListener { finish() }
    }

    private fun initView() {
        deletePop = CommonConfirmPop(this)

        offlineCacheAdapter = OfflineCacheAdapter()
        binding.recyclerView.apply {
            layoutManager = LinearLayoutManager(this@OfflineCacheActivity)
            adapter = offlineCacheAdapter
        }

        offlineCacheAdapter.setNewInstance(mutableListOf("", "", ""))
    }

    override fun initContentView(savedInstanceState: Bundle?): Int =
        R.layout.app_activity_offline_cache

    override fun initVariableId(): Int = BR.viewModel
}